<%@ page import="java.math.BigInteger" %><%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2023/3/21
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Insert title here</title>
</head>
<body>

<%
    BigInteger counter = (BigInteger) application.getAttribute("count");//当没有count访问的时候，返回的是null
    if (counter == null){
        counter = new BigInteger("0");
    }
    if (session.isNew()){//判断是否是新的用户（刷新的时候session不会变，所以不进行累加
        synchronized (this){
            counter =counter.add(new BigInteger("1"));//大整数进行加1
            application.setAttribute("count",counter);//application修饰全局
        }
    }
%>
<font color="red" size="6">您是第<%=counter %>个人访问该网站的用户</font>


</body>
</html>
